/**
 * klasse zur verwaltung der wichtigen einstellungen und variablen.
 * 
 */
package ch.unizh.ifi.ailab.config;

/**
 * @author hans jaeckle jaeckle@gmail.com
 * 
 */

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import ch.unizh.ifi.ailab.utils.Utils;

public class LocalizationSettings extends RobosuitcaseProperties {

	private static final long serialVersionUID = 1L;

	private String configPath = Utils.path(System.getProperty("user.dir"),
			"conf");

	private static LocalizationSettings myProperties = null;

	// logging
	// private static Logger myLog = Logger.getLogger(ProgramSettings.class);

	// singleton zum sicherstellen, dass nur eine instanz im programm!
	private LocalizationSettings() {
		configDefaults();
		// saveProperties("default values");
		// saveProperties(new File(currentPropertiesPath), "current
		// properties");
	}

	public static LocalizationSettings getLocalizationSettings() {
		if (myProperties == null) {
			myProperties = new LocalizationSettings();
		}
		return myProperties;
	}

	public void configDefaults() {
		// Localization Defaults:
		// Naming: loc-<classname>-<fieldclass>(-<methodname>)
		// **Program:
		setProperty("loc-Gui-mainFrameTitle", "015 Remote Control Center");

		// **Tabs
		setProperty("loc-Gui-mainPanel", "Fernsteuerung");

		// **Labels
		setProperty("loc-Gui-message-loadedProperties",
				"Properties neu geladen.");
		setProperty("loc-Gui-message-newProperties", "neue Properties: ");
		setProperty("loc-Gui-message-AIOut", "KI aus");
		setProperty("loc-Gui-message-AIOn", "KI ein");
		setProperty("loc-Gui-message-Speed", "Geschwindigkeit: ");
		setProperty("loc-Gui-message-Direction", "Richtung: ");
		setProperty("loc-Gui-message-AIMode", "KI Modus: ");
		setProperty("loc-Gui-message-NoSuitcase", "Keinen Koffer Gefunden!");
		setProperty("loc-Gui-message-Connecting", "Versuche zu verbinden.");
		setProperty("loc-Gui-message-SuitcaseNotRunning",
				"Koffer nicht gestartet");

		// **Buttons:
		setProperty("loc-Gui-buttonUp", "Schneller");
		setProperty("loc-Gui-buttonDown", "Langsamer");
		setProperty("loc-Gui-buttonLeft", "Links");
		setProperty("loc-Gui-buttonRight", "Rechts");
		setProperty("loc-Gui-buttonStop", "STOPP!!!");
		setProperty("loc-Gui-buttonKiMode", "KI/RC");
		setProperty("loc-Gui-buttonStartSuit", "Koffer Start");
		setProperty("loc-Gui-buttonStartCam", "Kamera Start");
		// **Menu:
		setProperty("loc-Gui-menuFile", "Steuerung");
		setProperty("loc-Gui-itemMock", "Mock Site Verwenden");
		setProperty("loc-Gui-itemLoadDefaultConfig",
				"Standard Einstellungen Wiederherstellen");
		setProperty("loc-Gui-itemLoadConfig", "Einstellungen Laden");
		setProperty("loc-Gui-itemSaveConfig", "Einstellungen Speichern");
		setProperty("loc-Gui-itemEditConfig", "Einstellungen Ver�ndern");
		setProperty("loc-Gui-itemExit", "Beenden");

		setProperty("loc-Gui-menuSuit", "Koffer");
		setProperty("loc-Gui-itemSuitStart", "Koffer Starten");
		setProperty("loc-Gui-itemSuitStop", "Koffer Stopppen");
		setProperty("loc-Gui-itemSuitRestart", "Koffer Neu Starten");
		setProperty("loc-Gui-itemSuitReset", "Koffer und KI Reset");
		setProperty("loc-Gui-itemSuitSwitchMode", "KI/Remote Umschalten");

		setProperty("loc-Gui-menuCam", "Kamera");
		setProperty("loc-Gui-itemCamStart", "Kamera Starten");
		setProperty("loc-Gui-itemCamStop", "Kamera Stoppen");
		setProperty("loc-Gui-itemCamRestart", "Kamera Neu Starten");
		setProperty("loc-Gui-itemCamRecord", "Aufnahme Starten");

		setProperty("loc-Gui-menuAI", "KI");
		setProperty("loc-Gui-itemAIMode1VectorSMC", "Vektor SMC");

		setProperty("loc-Gui-menuHelp", "Hilfe");
		setProperty("loc-Gui-itemHelpInfo", "Info");
		setProperty("loc-Gui-itemHelpDoc", "Dokumentation");

		setProperty("loc-Gui-menuLocale", "Sprache");
		setProperty("loc-Gui-itemLocaleEn", "EN - English");
		setProperty("loc-Gui-itemLocaleDe", "DE - Deutsch");

		// ********
		// New GUI 2007
		// ********
		// **Program:
		setProperty("loc-Gui2007-title", "Null15 AI Control - 2007");
		// **GuiMenu:
		setProperty("loc-Gui2007-fileMenu", "File");
		setProperty("loc-Gui2007-suitcaseMenu", "Suitcase");
		setProperty("loc-Gui2007-cameraMenu", "Camera");
		setProperty("loc-Gui2007-aiMenu", "AI");
		setProperty("loc-Gui2007-helpMenu", "Help");
		setProperty("loc-Gui2007-openPropFileMenuItem", "Load Properties");
		setProperty("loc-Gui2007-savePropFileMenuItem", "Save Properties");
		setProperty("loc-Gui2007-resetDefaultPropMenuItem",
				"Reload Default Properties");
		setProperty("loc-Gui2007-mockSuitMenuItem", "Run Mock Suitcase");
		setProperty("loc-Gui2007-exitMenuItem", "Exit");
		setProperty("loc-Gui2007-saveAsPropFileMenuItem", "Save Properties As");
		setProperty("loc-Gui2007-startSuitMenuItem", "Start Suitcase");
		setProperty("loc-Gui2007-stopSuitMenuItem", "Stop Suitcase");
		setProperty("loc-Gui2007-startCamMenuItem", "Start Camera");
		setProperty("loc-Gui2007-stopCamMenuItem", "Stop Camera");
		setProperty("loc-Gui2007-recordMenuItem", "Video Recorder");
		setProperty("loc-Gui2007-snapShotMenuItem", "Take Snapshot");
		setProperty("loc-Gui2007-startAiMenuItem", "Start AI Mode");
		setProperty("loc-Gui2007-stopAiMenuItem", "Return To RC Mode");
		setProperty("loc-Gui2007-aboutMenuItem", "About");
		setProperty("loc-Gui2007-helpMenuItem", "Help");
		// **GuiButtons:
		setProperty("loc-Gui2007-notStopButton", "EMERGENCY");
		// **GuiTabs:
		setProperty("loc-Gui2007-tabbedPaneRemote", "Remote");
		setProperty("loc-Gui2007-tabbedPaneSettings", "Settings");
		// **GuiMessages:
		setProperty("loc-Gui2007-overWriteMessage",
				" existiert bereits. Soll ueberschrieben werden?");

		// *********
		// **SteeringTab:
		setProperty("loc-SteeringTab-welcome", "Welcome To The Robosuitcase 2007");
		setProperty("loc-SteeringTab-fasterButton", "Faster");
		setProperty("loc-SteeringTab-remoteButton", "AI / RC");
		setProperty("loc-SteeringTab-leftButton", "Left");
		setProperty("loc-SteeringTab-rightButton", "Right");
		setProperty("loc-SteeringTab-slowerButton", "Slower");
		setProperty("loc-SteeringTab-stopButton", "Stop");
		setProperty("loc-SteeringTab-suitcaseButton", "Robot");
		setProperty("loc-SteeringTab-cameraButton", "Camera");
		setProperty("loc-SteeringTab-recordButton", "Record");
		setProperty("loc-SteeringTab-snapButton", "Snap");

		setProperty("loc-SteeringTab-infoLine1", "Koffer - Fersteuerung: ");
		setProperty("loc-SteeringTab-infoLine2", "Aktuelles Kommando: ");
		setProperty("loc-SteeringTab-infoLine3", "Sensordaten: ");
		setProperty("loc-SteeringTab-infoLine4", "Noch einfuegen...;)");

		// ********
		// **AboutDialog:
		setProperty("loc-About2007-title", "Null15 AI Control - About");
		setProperty("loc-About2007-message-rightsReserved",
				"All rights reserved.");
		setProperty("loc-About2007-message-web", "www.015.ch");
		setProperty("loc-About2007-message-project",
				"Project 015, University of Zurich");
		setProperty("loc-About2007-message-author", "Hans Jaeckle");
		setProperty("loc-About2007-message-null15AIControl",
				"Null15 AI Control with Gui2007");
		setProperty("loc-About2007-message-buttonOK", "OK");
		
		// ********
		// **EditorTab:
		setProperty("loc-EditorTab-cloumnsKey", "Property Key");
		setProperty("loc-EditorTab-cloumnsValue", "Property Value");
		setProperty("loc-EditorTab-saveButton", "Save");
		setProperty("loc-EditorTab-loadButton", "Load");
		setProperty("loc-EditorTab-loadDefaultsButton", "Load Defaults");
		setProperty("loc-EditorTab-infoLine1", "Placeholder Message...");
		setProperty("loc-EditorTab-infoLine2", "Placeholder Message...");

		File defaultFile = new File(Utils.path(configPath,
				"localization_default.prop"));
		FileOutputStream os = null;
		try {
			os = new FileOutputStream(defaultFile);
			String comment = "User Saved Properties";
			storeToXML(os, comment, ENCODING);
			setProperty("current", defaultFile.getPath());
		} catch (NullPointerException e) {
		} catch (FileNotFoundException e) {
		} catch (IOException e) {
		} finally {
			if (os != null) {
				try {
					os.close();
				} catch (IOException e) {
				}
			}
		}
	}
}
